//
//  YZYZAboutProductFooterView.m
//  kuaiyi
//
//  Created by 刘邓诏初 on 16/5/5.
//
//

#import "YZAboutProductFooterView.h"

@interface YZAboutProductFooterView()
/// 用户交流标签
@property(nonatomic,strong)UILabel *contactLabel;
/// 版本标签
@property(nonatomic,strong)UILabel *versionLabel;
@end

@implementation YZAboutProductFooterView

/// 返回底部 view
+ (instancetype)aboutProductFooterView{
    return [[self alloc] init];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder:aDecoder]) {
        [self prepareUI];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self prepareUI];
    }
    return self;
}

- (void)prepareUI{
    // 添加控件
    [self addSubview:self.contactLabel];
    [self addSubview:self.versionLabel];
    
    // 禁用 Autoresizing
    self.contactLabel.translatesAutoresizingMaskIntoConstraints = NO;
    self.versionLabel.translatesAutoresizingMaskIntoConstraints = NO;
    
    // 添加约束
    // 版本标签
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.versionLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.versionLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1 constant:-56]];
    // 用户交流标签
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.contactLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.versionLabel attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.contactLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.versionLabel attribute:NSLayoutAttributeTop multiplier:1 constant:-14]];
}

#pragma mark - 懒加载
- (UILabel *)contactLabel{
    if (_contactLabel == nil) {
        _contactLabel = [[UILabel alloc] init];
        _contactLabel.text = @"用户交流群：88888888";
        _contactLabel.textColor = [UIColor colorWithRed:35/255.0 green:187/255.0 blue:185/255.0 alpha:1];
    }
    return _contactLabel;
}

- (UILabel *)versionLabel{
    if (_versionLabel == nil) {
        _versionLabel = [[UILabel alloc] init];
        _versionLabel.text = @"Version : 1.4.0";
        _versionLabel.textColor = [UIColor colorWithRed:187/255.0 green:187/255.0 blue:187/255.0 alpha:1];
    }
    return _versionLabel;
}

@end
